package cn.magicman.demo;

public class NoVisibility {
    private static boolean ready;
    private static int number;
    
    private static class ReaderThread extends Thread {
        public void run() {
            while (!ready) {
                Thread.yield();
            }
            System.out.println(number);
        }
    }
    
    public static void main(String[] args) {

        for (int i = 0; i < 10000; i++) {
            ready = false;
            number = 0;
            new ReaderThread().start();
            number = 42;
            ready = true;
        }
    }
}